﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ConfApp.Infrastracture.HttpClient;
using ConfApp.Infrastructure;
using ConfApp.Models;
using ConfApp.Models.Dto;
using Microsoft.Phone.Reactive;

namespace ConfApp.Services.ConfDataService
{
    public class ConfDataServiceClient : IConfDataServiceClient
    {
        private readonly string _confDataServiceUrl;

        public ConfDataServiceClient(string confDataServiceUrl)
        {
            _confDataServiceUrl = confDataServiceUrl;
        }

        public IObservable<ConfAppModelDto> GetData(int version, string phoneMspnUrl, IEnumerable<Speaker> speakers)
        {
            var uri = new Uri(_confDataServiceUrl);
            return
                HttpClient
                    .RequestTo(uri)
                    .PostJsonAndGetResult<QueryParamsDto, ConfAppModelDto>(
                        new QueryParamsDto
                            {
                                Version = version,
                                URL = phoneMspnUrl
                            }
                    );
        }
    }
}
